package com.demo.unittest.springweb.dao;

import com.demo.unittest.springweb.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author tzp
 * @since 2018/4/28
 */
@Repository
@Mapper
public interface UserDAO {

    @Select("SELECT * FROM `st_user` WHERE `name` = #{name} and `password` = #{password}")
    User getUserByPassword(@Param("name") String name, @Param("password") String password);

    @Insert("insert into `st_user` values(#{user.id}, #{user.name}, #{user.password})")
    void insertUser(@Param("user") User user);

    @Select("select * from `st_user`")
    List<User> listAllUser();
}
